package com.woniuxy.service.impl;


import com.woniuxy.dao.RoleMenuDao;
import com.woniuxy.service.RoleMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 星星
 */
@Service
public class RoleMenuServiceImpl implements RoleMenuService {
    @Resource
    RoleMenuDao roleMenuDao;
    @Override
    public int insertMenus(int role_id,int[] menus) {
        List list = new ArrayList();
        for (int menu: menus) {
            Map<String,Integer> map = new HashMap<>();
            map.put("role_id",role_id);
            map.put("perm_id",menu);
            list.add(map);
        }
        roleMenuDao.deleteById(role_id);
        int row = roleMenuDao.insertMenus(list);
        return row;
    }

    @Override
    public List<Integer> selectById(int role_id) {
        return roleMenuDao.selectById(role_id);
    }
}
